<extend name="Base/common" />

<block name="style">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Api/css/order.css">
</block>

<block name="Content">

<div class="page-group">
    <div class="page page-current pay-details">
        <div class="order-foot bar bar-standard bar-footer">
            <div class="content-block order-foot-block">
                <div class="row">
                    <div class="col-100">
                    	<form action="" method="post" id="dataform">
	                    	<a href="#" onclick="addAddress()" class="button button-big button-fill button-pay">添加地址</a>
	                    	<input type="hidden" name="type" id="type" value="{$type}"/>
	                    	<input type="hidden" name="data" id="data" value='{$data}'/>
	                    	<input type="hidden" name="address_id" id="address_id" value=""/>
                    	</form>
                    </div>
                </div>
            </div>
        </div>
        <div class="content address">
            <div class="list-block media-list">
            	<notempty name="list">
					<foreach name="list" item="address">
					
						<ul class="address-details">
		                    <li>
		                        <label class="label-checkbox item-content">
		                        	<if condition="$type eq '2'">
		                        		<input type="radio" name="address_id" id="address_id" value="{$address['address_id']}">
		                        	</if>
		                            <div class="item-media">
		                            	<if condition="$type eq '2'">
		                            		<i class="icon icon-form-checkbox"></i>
		                            	</if>
		                            </div>
		                            <div class="item-inner">
		                                <div class="item-title-row">
		                                    <ul>
		                                        <li><span>客户姓名：</span><span>{$address['contact']}</span></li>
		                                        <li><span>联系电话：</span><span>{$address['telphone']}</span></li>
		                                        <li>
		                                            <span>维修地址：</span><span class="address-span">{$address['address']}</span>
		                                        </li>
		                                    </ul>
		                                </div>
		                            </div>
		                        </label>
		                    </li>
		                    <div class="icon-write" address-id="{$address['address_id']}"></div>
		                </ul>
					</foreach>
				</notempty>
            </div>
        </div>
    </div>
</div>

</block>

<block name="script">
<script type="text/javascript">

$("input[type='radio']").on('change', function(){
	$("#address_id").val($(this).val());
	var target = Think.U('UserAddress/order');
	$("#dataform").attr('action', target);
	$(document).find('form').submit();
});

$(".icon-write").on('click', function(){
	$("#address_id").val($(this).attr('address-id'));
	var target = Think.U('UserAddress/editAction');
	$("#dataform").attr('action', target);
	$(document).find('form').submit();
});

function addAddress(){
	$("#address_id").val('');
	var target = Think.U('UserAddress/editAction');
	$("#dataform").attr('action', target);
	$(document).find('form').submit();
}
</script>
</block>

